class Solution {
public:
    int numEquivDominoPairs(vector<vector<int>>& dominoes) {
        vector<int> ret(100, 0);
        int cnt = 0;
        for (auto num : dominoes) {
            int val = (num[0] > num[1] ? num[0] * 10 + num[1] : num[1] * 10 + num[0]);
            cnt += ret[val];
            ++ret[val];
        }
        return cnt;
    }
};
